;

#ifndef _MESSAGE_QUEUE_H_
#define _MESSAGE_QUEUE_H_

#include "gamemessage.h"

#include <string>
#include <map>
#include <queue>

using namespace std;

#define SEND_MSG_ARGS(sender, receiver, key, value)       MessageQueue::getInstance()->send(MessageData(sender, receiver, key, value))
#define SEND_MSG(s)                         MessageQueue::getInstance()->send(s)
#define PEEK_MSG(s)                    MessageQueue::getInstance()->peek(s)
#define POP_MSG(s)                     MessageQueue::getInstance()->pop(s)

class MessageQueue {
public:
	static MessageQueue* getInstance();
	~MessageQueue();

	void send(const MessageData& msg);
	MessageData * peek(MessageTarget receiver);
	void pop(MessageTarget receiver);
	void clear(MessageTarget target = MessageTarget::all);

private:
	MessageQueue();
	static MessageQueue* _instance;

	void init();
	
	map<MessageTarget, queue<MessageData> > _mapMessages;
};

#endif
